package com.carworld.utils;

import java.io.File;
import java.math.BigDecimal;

import com.jfinal.kit.StrKit;
import com.jfinal.upload.UploadFile;

public class FileUtil {
	
	public static String reName(UploadFile file) {
		String fileName = file.getFileName() ;
		String fileType = fileName.substring(fileName.lastIndexOf("."));
		File uploadedFile = new File(file.getUploadPath() +  File.separator + fileName ) ;
		String newName =  StrKit.getRandomUUID() + fileType ;
		uploadedFile.renameTo(new File(file.getUploadPath() + File.separator + newName)) ;
		return newName ;
	}
	
	public static int getAmount(String valueString) {
		Float float1 = Float.parseFloat(valueString);
		float1 = float1*100 ;
		return Math.round(float1);
	}
		
		
		
		public static String getFloat(int amount) {
			BigDecimal bigDecimal = new BigDecimal(amount);
			bigDecimal = bigDecimal.divide(new BigDecimal(100));
			return bigDecimal.setScale(2,BigDecimal.ROUND_HALF_UP).floatValue() + "";
		}
		
	
		

		
}
